<!DOCTYPE html>
<html lang="zn">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>立项失败</title>
  <meta name="description" content="">
  <meta name="author" content="templatemo">
  <link href="../css/font-awesome.min.css" rel="stylesheet">
  <link href="../css/bootstrap.min.css" rel="stylesheet">
  <link href="../css/templatemo-style.css" rel="stylesheet">
  <link href="../css/admin.css" rel="stylesheet">
  <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
  <script src="../js/admin.js"></script>
</head>
  <script>
    function delpro(id){
      if(window.confirm('确定删除吗？')){
          $.ajax({
                type: "GET",
                url: 'dodelPro.php',
                async: false,
                dataType: "json",
                data: {
                    'pid':id
                },
                success: function (msg) {
                    if (msg.status == 1) {
                        alert(msg.mes);
                        window.location.reload();
                    }
                    if (msg.status == -1) {
                        alert(msg.mes);
                        window.location.reload();
                    }
                },
                error: function (result) {
                    alert('请求失败!');
                }
            });
      }
    }
  </script>
<body>
  <?php
    require_once "../congfig/config.php";
    require_once "../lib/common.php";
    session_start();
    checkAdmin();
    $i= 1;
    $sql = "select * from proinfor  ";
    $query = $GLOBALS['conn']->query($sql);
    $num = $query->num_rows;
    $pagesize = 4;
    $page = empty($_GET['page']) ? 1 : $_GET['page'];
    $prepage = $page - 1;
    $nextpage = $page + 1;
    $tatolpage = ceil($num / $pagesize);
    $startpage = ($page - 1) * $pagesize;
    @$key = $_GET['key'];
    if (isset($key)) {
        $sql = "select * from proinfor where pName like '%$key%'";
        $query = $GLOBALS['conn']->query($sql);
    } else {
        $sql = "select * from proinfor    where pRank = '5'";
        $query = $GLOBALS['conn']->query($sql);
    // $result=$query1->fetch_array();
    // echo $result['pName'];
    }

    ?>
  
  <!-- Left column -->
  <div class="templatemo-flex-row">
    <div class="templatemo-sidebar">
      <header class="templatemo-site-header">
        <div class="square"></div>
        <h1>后台管理系统</h1>

      </header>

      <div class="profile-photo-container">
        <img src="../images/profile-photo.jpg" alt="Profile Photo" class="img-responsive">
      </div>
      <!-- Search box -->

      <div class="mobile-menu-icon">
        <i class="fa fa-bars"></i>
      </div>
      <nav class="templatemo-left-nav">
        <ul>
          <li id="xmgl"><a href="project-list.php" class="active"><i class="fa fa-bars fa-fw"></i>项目管理</a>
            <ul>
              <li><a href="addProject.php"><i class="fa fa-bars fa-fw"></i>添加项目</a></li>
            </ul>
            <ul>
              <li><a href="applyproject.php"><i class="fa fa-bars fa-fw"></i>申请立项</a></li>
            </ul>
            <ul>
              <li><a href="projectsucc.php"><i class="fa fa-bars fa-fw"></i>立项成功</a></li>
            </ul>
            <ul>
              <li><a href="projectfail.php"><i class="fa fa-bars fa-fw"></i>立项失败</a></li>
            </ul>
            <ul>
              <li><a href="applyprojectover.php"><i class="fa fa-bars fa-fw"></i>申请结项</a></li>
            </ul>
            <ul>
              <li><a href="projectok.php"><i class="fa fa-bars fa-fw"></i>结项成功</a></li>
            </ul>
            <ul>
              <li><a href="#"><i class="fa fa-bars fa-fw"></i>结项失败</a></li>
            </ul>
            <ul>
              <li><a href="goodpro.php"><i class="fa fa-bars fa-fw"></i>优秀项目</a></li>
            </ul>
          </li>
          <li id="yhgl"><a href="user-list.php"><i class="fa fa-user fa-fw"></i>用户管理</a>
            <ul>
              <li><a href="addUser.php"><i class="fa fa-user fa-fw"></i>添加用户</a></li>
            </ul>
          </li>
          <li><a href="pad-check.php"><i class="fa fa-cog fa-fw"></i>修改密码</a></li>
          <li><a href="../loginout.php" id="zx"><i class="fa fa-map-marker fa-fw"></i>注销</a></li>
        </ul>
      </nav>
    </div>
    <!-- Main content -->
    <div class="templatemo-content col-1 light-gray-bg" style="height:1000px;">
      <div class="container" style="margin-top:100px;">
        <div role="tabpanel" class="tab-pane active" id="sour">
          <div class="check-div form-inline">
            <form action="#" method="GET">
            <div class="col-xs-4">
              <input type="text" class="form-control input-sm"  name="key" placeholder="输入项目名搜索">
              <button type="submit" class="btn btn-white btn-xs  ">查 询 </button>
              <!-- <a class="btn btn-white btn-xs" href="project-list.php?key=<?php echo $key ?>"></a> -->
            </div>
            </form>
          </div>
          <div class="data-div">
            <table class="table table-hover table-striped">
              <thead>
                <tr>
                  <td>编号</td>
                  <td>项目名称</td>
                  <td>项目负责人</td>
                  <td>指导教师</td>
                  <td>操作</td>
                </tr>
              </thead>
              <tbody>
                <?php while ($result = $query->fetch_array()) {
                    ?>
                <tr>
                  <th><?php echo $i++; ?></th>
                  <th><?php echo $result["pName"]; ?> </th>
                  <?php
                    $username = $result["pChar"];
                    $sql1 = "select * from userinfor where uid =(select uid from users where username='$username')";
                    $query1 = $conn->query($sql1);
                    $result1 = $query1->fetch_array();
                    ?>
                  <th><?php echo $result1["realname"]; ?></th>
                  <?php
                    $username1 = $result["teacher"];
                    $sql2 = "select * from userinfor where uid =(select uid from users where username='$username1')";
                    $query2 = $conn->query($sql2);
                    $result2 = $query2->fetch_array();
                    ?>
                  <th><?php echo $result2["realname"]; ?></th>
                  <th>
                    <a class="btn btn-info btn-xs" href="projectinfor.php?pid=<?php echo $result['id'] ?>">查看</a>

                  </th>
                </tr>
                <?php

            }

            ?>
              </tbody>
            </table>
            <?php
            if ($prepage <= 0) {
                $prepage = 1;
            }
            if ($nextpage > $tatolpage) {
                $nextpage = $page;
            }
            ?>    
          <?php
            if ($prepage < 0) {
                $prepage = 0;
            }
            if ($nextpage > $tatolpage) {
                $nextpage = $page;
            }
            ?>
          <footer class="footer pull-right">
              <!-- <ul class="pagination">
                <li><a href="project-list.php?page=0"><i class=" fa fa-fast-backward" style="color:rgb(19,137,95);font-size:20px;"></i></a></li>
                <li><a href="project-list.php?page=<?php echo $prepage ?>" ><i class="fa fa-backward " style="color:rgb(19,137,95);font-size:20px;  "></i></a></li>
                <li class="gray">
                  <span style="font-size:15px; height: 45px;padding-top:13px;">第 <?php echo $page ?> 页</span> 
                </li>
                <li><a href="project-list.php?page=<?php echo $nextpage ?>"><i class="  fa fa-forward" style="color:rgb(19,137,95);font-size:20px;"></i></a></li>
                <li><a href="project-list.php?page=<?php echo $tatolpage ?>"><i class=" fa fa-fast-forward" style="color:rgb(19,137,95);font-size:20px; "></i></a></li>
              </ul> -->
            </footer>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

</html>